﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Game_Admin_Demo.admin
{
    public partial class Category : System.Web.UI.Page
    {
        DataClasses1DataContext dc = new DataClasses1DataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ListView1.DataSource = dc.danhmucs;
                ListView1.DataBind();
              
               
                
            }
        }

        protected void LinkButton1_Click(object sender, EventArgs e)
        {
            LinkButton lb = (LinkButton)sender;
            HiddenField hd = (HiddenField)lb.FindControl("hd1");
            int madm = Convert.ToInt32(hd.Value);
            var dm = dc.danhmucs.SingleOrDefault(a => a.madm == madm);
            dc.danhmucs.DeleteOnSubmit(dm);
            dc.SubmitChanges();
            ListView1.DataSource = dc.danhmucs;
            ListView1.DataBind();
        }

        protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType==ListViewItemType.DataItem)
            {
                LinkButton lb =(LinkButton) e.Item.FindControl("LinkButton1");
                lb.Attributes.Add("onclick", "return confirm('sure')");
            }
        }
    }
}